<extend  name="Seller/base" />
<block name="head">
  <meta http-equiv="refresh" content="180">
</block>
<block name="main">
        <div class="mem_t">订单信息</div>
        <table border="0" class="acc_tab" style="width:870px;" cellspacing="0" cellpadding="0" id="data">
               <thead>
                  <tr> 
                    <th>菜名</th>
                    <th>数量</th>
                    <th>下单时间</th>           
                    <th>状态</th>
                    <th>备注</th>
                    <th>操作</th>
                  </tr>
              </thead>
              <tbody>
                <foreach name="list" item="me">
                  <tr>
                    <td>{$me.menu}</td>                  
                    <td>{$me.num}</td>
                    <td>{$me.start_time|date="Y-m-d H:i:s",###}</td>
                    <td><if condition="($me.state eq 1) ">已下单<elseif condition="($me.state eq 2) "/>已接单<elseif condition="($me.state eq 3) "/>配送中<elseif condition="($me.state eq 4) "/>已完成<elseif condition="($me.state eq 5) "/>已拒接</if></td>
                    <td>{$me.remark}</td> 
                    <td>
                      订单详情<br>
                      <span id="caozuo{$me.id}">
                      <if condition="($me.state eq 1) "><a onclick="accept({$me.id})">接单</a>|<a onclick="refuse({$me.id})">拒接</a>
                      <elseif condition="($me.state eq 2) "/><a onclick="send({$me.id})">配送</a>
                      <elseif condition="($me.state eq 3) "/><a onclick="">骑手准备中</a>
                      <elseif condition="($me.state eq 4) "/><a onclick="">骑手配送中</a>
                      <elseif condition="($me.state eq 5) "/><a onclick="">配送完成</a>
					  <elseif condition="($me.state eq 6) "/><a onclick="">已拒接</a>
                      </if>
                      </span>
                    </td>    
                  </tr>
                </foreach>
              </tbody>
              <!-- 新订单判断 -->
              <if condition="($me.state eq 1) ">
              <audio  autoplay>
                <source src="__PUBLIC__/images/song.mp3" type="audio/mpeg">
                <source src="__PUBLIC__/images/song.mp3" type="audio/ogg">
                <embed height="50" width="100" src="__PUBLIC__/images/song.mp3">
              </audio>
              </if>
         </table>
</block>
<block name="js">
   <script type="text/javascript">
     function accept(id){
            $.ajax({
              type:"POST",
              url: '__CONTROLLER__/accept',
              data:"id="+id,
              dataType:"json",
              success:function(res){
                if (res) {
                  $("#caozuo"+id).html('<a onclick="send({$me.id},this)">发货</a>');
                }else{
                  alert("接单失败！请联系管理员");
                }
              }
            });
      }
      function send (id) {
         $.ajax({
              type:"POST",
              url: '__CONTROLLER__/send',
              data:"id="+id,
              dataType:"json",
              success:function(res){
                if (res) {
                  $("#caozuo"+id).html('<a onclick="">配送中</a>');
                }else{
                  alert("发货失败！请联系管理员");
                }
              }
            });
      }
      function refuse(id){
          $.ajax({
              type:"POST",
              url: '__CONTROLLER__/refuse',
              data:"id="+id,
              dataType:"json",
              success:function(res){
                if (res) {
                  $("#caozuo"+id).html('<a onclick="">已拒绝</a>');
                }else{
                  alert("发货失败！请联系管理员");
                }
              }
            });
      }
      // 检测是否有新订单
      

   </script>
</block>